package samples.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import samples.spring.beans.SayHelloService;
import samples.spring.beans.User;

/**
 * Spring基础用法
 */
public class SpringStep1 {

    public static final Logger LOGGER = LoggerFactory.getLogger(SpringStep1.class);

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:step1.xml");
        LOGGER.info("==============classpathxmlapplicationcontext create completed.");
        User user = context.getBean(User.class);
        LOGGER.info("=============={}", user);

        SayHelloService sayHelloService = context.getBean(SayHelloService.class);
        String sayHello = sayHelloService.sayHello(user.getName());
        LOGGER.info("=============say result:{}", sayHello);
    }
}
